// JavaScript Document
//buypg ajax 操作

//
function ajax_loading(){
	
}

function ajax_load(id , url){
	var op_ajax = "?inajax=1";
	url = url+op_ajax;
	$(id).load(url);
}

function ajax_page(event , ctrlid , id){
	var op_ajax = "?inajax=1";
	var href = $("#"+ctrlid).attr("href");
	href = href + op_ajax;
	doane(event); //ajaxclick后，阻止元素的后续操作
	$(id).load(href);
}

function ajax_checklogin(form){
		$.ajax({
			type:"post",
			url:URL+"/checklogin",
			data: $("#"+form).serialize(),
			dataType: "json",
			success : function(data){
				var html = '';
				$("span.return_value").html("<img src='"+PUBLIC+"/images/check_right.gif'/>");
				if(data.status){
					var dg = new $.dialog({ 
						id:'loginsuccess', 
						html:'<div style="text-align:center; padding:10px; height:100px;line-height:100px;"><h3>登录成功，现在将转入登录前的页面。</h3></div>',
						maxBtn : false,
						minBtn : false,
						btnBar : false,
						drag : false,
						iconTitle : false,
						title : 'Buypg欢迎您',
						width : 400,
						height: 200
					}); 
					dg.closeTime(
						3,
						function(){ 
							var n = 2; 
							setInterval(function(){ dg.SetTitle('窗口将在'+n+'秒钟后自动关闭'); n--; }, 1000);
						}
					);
					dg.closeAfter(
						3 , 
						function(){
							dg.SetTitle('窗口将在3秒钟后自动关闭');
							window.location.href = data.data['refer'];
						}
					);
					dg.ShowDialog();
					dg.SetXbtn(
						function(){
							dg.cancel();
							window.location.href = data.data['refer'];
						}
					); 
				}else{
					for (var key in data.data){
						html = "<img src='"+PUBLIC+"/images/check_error.gif'/> "+data.data[key]['return_info'];
						$("#return_"+data.data[key]['return_name']).html(html);
					}
					//重新刷新验证码
					fleshVerify()
				}
			}
		});
}

function ajaxSearch(){
	var keyword;
	keyword = $("input[name='ajaxkeyword']").attr("value");
	$("#website1").hide();
	$("#website2").show();
	$("#website2").load(APP+"/Search/ajaxsearch",{keyword : keyword},function(){});
	return false;
}

function ajaxSearchShow(siteid){
	$("#website2").load(APP+"/Search/ajaxsearchshow",{siteid : siteid},function(){});
}
